import { myEnv } from '@/myEnv';
import { mergeRequest } from '@/utils';
import { UserInfo_Web, UserInfo_Res } from '@/pages/_server/_class/Mine/UserInfo';
/** 获得用户信息 */
export const apiGetUserInfo = async () => {
    const response1: MyResponse<UserInfo_Res> = await sendRequest();
    if (!response1) return;
    const webData = new UserInfo_Web().immit_response(response1.data);
    const resonlse2: MyResponse<UserInfo_Web> = { ...response1, data: webData };
    return resonlse2;
};

const sendRequest = async () => {
    let response1: MyResponse<UserInfo_Res>;
    if (myEnv.IS_ON_LINE) {
        response1 = await mergeRequest({
            url: 'user/get-info',
            method: 'GET',
        });
    } else {
        response1 = {
            code: '200',
            message: 'ok',
            data: {
                userPhoneNumber: '+8613552231112',
                avatarUrl: '/img/avatar/13552231112.webp',
                nickName: '321561',
                contractAddress: 'testaddrxxxxxxxxxxxxx',
                realId: '511123199805172566',
                realName: '蒙婷',
                isRegisteredArtist: 0,
                hasIdentifiedRealName: 1,
            },
        };
    }
    return response1;
};
